<?php
/**
 * Created by PhpStorm.
 * User: zhanglili
 * Date: 2021/9/6
 * Time: 15:44
 */

include_once "third_cloud/Sample.php";
include_once "third_cloud/Tencent.php";
include_once "function.php";

$aliyun = new AlibabaCloud\SDK\Sample\Sample();
$tencent = new Tencent();

while (true) {
    $ip = readIp();
    if (empty($ip)) {
        $ip = get_onlineip();
        writeIp($ip);
    } else {
        $now_ip = get_onlineip();
        if ($ip != $now_ip) {
            $tencent::delete($ip);
            $aliyun::delete($ip);
            writeIp($now_ip);
        } else {
            echo "上次ip是:{$ip}，现在ip是:{$now_ip},ip没变,程序进行进入休眠,10分钟之后再次执行!\r\n";
            sleep(600);
            continue;
        }
        $ip = $now_ip;
    }
    //阿里云
    $aliyun::main($ip);
    //腾讯云
    $tencent::add($ip);
    echo "现在ip是:{$ip},已自动配置安全组,可直接链接服务器!\r\n";
    sleep(600);
}







